package biz.inspeed.test;

import java.util.ArrayList;

public class ParseString2Byte {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String str = "[25,216,255,224,0,16,74,70,73,70,0,1,1,1,0,96,0,96,0,00]";
		char beginChar = '[';
		char endChar = ']';
		char sepChar = ',';
		
		int i = 0,j = 1;
		char ch = str.charAt(j) ;
		int len = str.length();
		ArrayList<Byte> list = new ArrayList<Byte>();
		while(j < len){
			
			ch = str.charAt(j);
			if(ch == sepChar || ch == endChar){
				String str1 = str.substring(i+1, j);
				i = j;
				System.out.print(str1 + " ");
				int intValue = Integer.parseInt(str1);
			byte b = (byte) (intValue &0xff);
			list.add(b);
			
			}
			j ++;
		}
		Byte[] buf = new Byte[10];
		buf = list.toArray(buf);
		System.out.println("\n-----------------------");
		System.out.println(buf.length);
		
	}
}
